package q2535;

/**
 * 2535. 数组元素与数字和的绝对差
 */
public class Solution {

    public int differenceOfSum(int[] nums) {
        int sum1 = 0, sum2 = 0;
        for (int i = 0; i < nums.length; i++) {
            sum1 += nums[i];
            int num = nums[i];
            while (num > 0) {
                sum2 += num % 10;
                num /= 10;
            }
        }
        return Math.abs(sum2 - sum1);
    }


}
